﻿using System;
using System.Collections.Generic;
using CompactMapper.Orm.Annotations;
using CompactMapper.Orm.Contracts;
using CompactMapper.Orm.UnitOfWork.Mappings;

namespace CompactMapper.Orm.Tests
{
    [Table]
    public class Record : IKeyedPersistent
    {
        private readonly List<Track> _tracks = new List<Track>();

        [GuidPrimaryKey]
        public IKey Key { get; set; }

        [TextColumn]
        public String RecordName { get; set; }

        [Single]
        public Publisher Publisher { get; set; }

        [HasAndBelongsToMany]
        public IEnumerable<Track> Tracks { get { return _tracks; } }

        public void AddTrack(Track track)
        {
            _tracks.Add(track);
        }


        public Record()
        {
            Key = AbstractKeyFactory.For<Guid>().New();
        }
    }
}
